var t = require("../../../@babel/runtime/helpers/defineProperty"), a = getApp();

Page({
    data: {
        active: 0,
        allData: {},
        member: {},
        rewards: {},
        name: {},
        rewards_type: 1,
        recordsList: [],
        amount_id: "",
        not_rewarded: "",
        rewarded: "",
        page: 1,
        language: "",
        shareholderShowDetailsIndex: null,
        sameLevelShowDetailsIndex: null
    },
    onLoad: function(t) {
        this.initData(), this.getStatistic(), this.getData();
    },
    initData: function() {
        this.data.recordsList = [], this.data.page = 1, this.data.total_page = 0, this.data.isLoadMore = !0, 
        this.data.amount_id = "";
    },
    onReady: function() {
        var t = wx.getStorageSync("langIndex");
        this.setData({
            language: t.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        if (console.log(this.data.page), this.data.page >= this.data.total_page) console.log("没有更多"); else {
            var t = this.data.page + 1;
            this.setData({
                page: t
            }), this.getMoreData();
        }
    },
    onShareAppMessage: function() {},
    onClickLeft: function() {
        wx.navigateBack({
            delta: 1
        });
    },
    tabHandel: function(t) {
        this.data.rewards_type = t.detail.index + 1, this.initData(), this.getData(), this.setData({
            shareholderShowDetailsIndex: null,
            sameLevelShowDetailsIndex: null
        });
    },
    getData: function() {
        wx.showLoading({
            title: "加载中"
        });
        var t = this, e = a.getNetAddresss("plugin.partner-reward.frontend.controllers.reward-log.getLogByType");
        a._postNetWork({
            url: e,
            data: {
                page: t.data.page,
                reward_type: t.data.rewards_type
            },
            success: function(a) {
                var e = a.data;
                wx.hideLoading({
                    success: function(t) {}
                }), 1 == e.result ? t.setData({
                    recordsList: e.data.data,
                    not_rewarded: e.data.not_rewarded,
                    rewarded: e.data.rewarded,
                    total_page: e.data.last_page
                }) : wx.showToast({
                    title: e.msg,
                    duration: 1e3,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t.msg);
            }
        });
    },
    getMoreData: function() {
        wx.showLoading({
            title: "加载中"
        });
        var t = this, e = a.getNetAddresss("plugin.partner-reward.frontend.controllers.reward-log.getLogByType");
        a._postNetWork({
            url: e,
            data: {
                page: t.data.page,
                reward_type: t.data.rewards_type
            },
            success: function(a) {
                var e = a.data;
                wx.hideLoading({
                    success: function(t) {}
                }), 1 == e.result ? (t.data.recordsList = t.data.recordsList.concat(e.data.data), 
                t.setData({
                    recordsList: t.data.recordsList
                })) : wx.showToast({
                    title: e.msg,
                    duration: 1e3,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t.msg);
            }
        });
    },
    getStatistic: function() {
        wx.showLoading({
            title: "加载中"
        });
        var t = this, e = a.getNetAddresss("plugin.partner-reward.frontend.controllers.reward-log.index");
        a._postNetWork({
            url: e,
            success: function(a) {
                var e = a.data;
                wx.hideLoading({
                    success: function(t) {}
                }), 1 == e.result ? (wx.setNavigationBarTitle({
                    title: e.data.name
                }), t.setData({
                    rewards: e.data
                })) : wx.showToast({
                    title: e.msg,
                    duration: 1e3,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t.msg);
            }
        });
    },
    showDetails: function(a) {
        var e = a.currentTarget.dataset.index, s = null, n = "";
        "shareholder" === a.currentTarget.dataset.tab ? (s = this.data.shareholderShowDetailsIndex, 
        n = "shareholderShowDetailsIndex") : (s = this.data.sameLevelShowDetailsIndex, n = "sameLevelShowDetailsIndex"), 
        s == e && (e = null), console.log(n), this.setData(t({}, n, e));
    }
});